package com.fast.develop.management.resource.compoment;

import cn.hutool.core.util.StrUtil;
import com.fast.develop.core.io.ResourceManager;
import com.fast.develop.management.resource.utils.SchemaFileUtil;

/**
 * @author 莫寅
 * @createTime 2022-06-17 11:26
 * @desc：
 */
public class FileCreator {

    private ResourceManager resourceManager;

    public FileCreator(ResourceManager resourceManager) {
        this.resourceManager = resourceManager;
    }

    public void createFolder(String path){
        resourceManager.createFolder(path);
    }

    public void createFile(String path){
        String suffix = SchemaFileUtil.getSuffix(path);
        if(StrUtil.isBlank(suffix)){
            path += ".json";
        }
        resourceManager.createFile(path);
    }

    /**
     * 重命名
     * @param path
     * @param newName
     */
    public String rename(String path, String newName){
        return resourceManager.rename(path, newName);
    }
}
